<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib uri="/WEB-INF/c.tld" prefix="c" %> 
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<link rel="stylesheet" href="<%=request.getContextPath()%>/public/css/style.model.css">
<!-- core -->
<script src="<%=request.getContextPath()%>/public/js/jquery-1.5.1.min.js"></script>
<!-- dataTable -->
<script src="<%=request.getContextPath()%>/public/js/jquery-ui-1.8.13.custom.min.js"></script>
<!-- dataTable -->
<script src="<%=request.getContextPath()%>/public/js/jquery.dataTables.js"></script>
</head>
<body>
<div class="container">
<h2>栏位设置</h2>
<div class="toolbar">
	<ul><li><a href="#">Back</a></li><li><a id="" class="save-btn" href="#">Save</a></li></ul>
	<div class="cl"></div>
</div>
<form method="post" action="<%=request.getContextPath()%>/c?s=model&o=addreleation&m_id=${model.m_id}" class="form">
<table cellpadding="0" cellspacing="0" border="0" class="display" id="example">
	<thead>
		<tr>
			<th>字段</th>
			<th>自增</th>
			<th>主键</th>
			<th>选择控件</th>
			<th>描述</th>
			<th>提示</th>
			<th>为空</th>
			<th>显示</th>
			<th>数据源</th>
		</tr>
	</thead>
	<tbody>
	<c:set var="f" value="1" />
	<c:forEach var="field" items="${fields }">
	<c:set var="f" value="${f+1 }" />
	<tr class='grade<c:if test="${f%2==0}">B</c:if><c:if test="${f%2!=0}">A</c:if>'>
		<td><input type="text" readonly="readonly" name="${f }~mc_attr_name" value="${field.Field}" /></td>
		<td><input type="checkbox" class="toggle-radio" />
		<input type="hidden" name="${f }~mc_auto" value="0"/>
		</td>
		<td><input type="checkbox" class="toggle-radio" />
		<input type="hidden" name="${f }~mc_pri" value="0"/>
		</td>
		<td>
			<select name="${f }~mc_control_id">${ options}</select>
		</td>
		<td><input type="text" name="${f }~mc_tip" readonly="readonly" value="${field.Comment}" /></td>
		<td><input type="text" name="${f }~mc_prompt" value="${field.Comment}" /></td>
		<td><input type="checkbox" class="toggle-radio"/>
		<input type="hidden" name="${f }~mc_null" value="0" />
		</td>
		<td><input type="checkbox" class="toggle-radio" checked="checked"/>
		<input type="hidden" name="${f }~mc_show" value="1" />
		</td>
		<td><select name="${f }~mc_ds">${ datasets}</select></td>
	</tr>
	</c:forEach>
	</tbody>
</table>
</form>
</div>
<script type="text/javascript">
	$().ready(function(){
		$("#example").dataTable({
	        "bJQueryUI": true,
	        "sPaginationType": "full_numbers"
	    });
		$(".save-btn").click(function(){
			$(".form").submit();			
		});
		$(".toggle-radio").each(function(){
			$(this).click(function(){
				var v = parseInt($(this).next().val());
				$(this).next().val(v==1?0:1);
			});
		});
<c:if test="${msg!=null}">alert('${msg}');</c:if>
	});
</script>
</body>
</html>